#include "controller/motor.h"

motor_t g_motor[1];

void motor_init(motor_t *motor){
    memset(motor, 0, sizeof(motor_t));
    mc_conf_init();
	contrl_init(controller(motor));
}

bool motor_start(motor_t *motor, u8 mode) {

    return true;
}

bool motor_stop(motor_t *motor) {

    return true;
}


void mc_fault_irq_handler(motor_t *motor){

}

void timer_up_irq_handler(motor_t *motor){

}

/*ADC 电流采集中断，调用FOC的核心处理函数*/
void motor_adc_irq_handler(motor_t *motor) {
	controller_t *ctrl = controller(motor);
	ctrl->encoder_angle = motor_get_encoder_angle(motor);
	ctrl->encoder_velocity = motor_get_encoder_velocity(motor);
	contrl_adc_update(controller(motor));
}

/*slow的部分处理，比如速度环，状态机，转把采集等*/
void mc_sched_irq_handler(motor_t *motor) {

}
